function insertSort (arr) {
  for (let i = 0; i < arr.length - 1; i++) {
    for (let j = i + 1; j > 0; j--) {
      if (arr[j - 1] > arr[j]) {
        [arr[j - 1], arr[j]] = [arr[j], arr[j - 1]]
      }
    }
  }
  return arr
}
let arr = [2, 5, 3, 7, 6, 4, 21, 13, 1]
console.log(insertSort(arr))
